
/* Sudoku definitions */

#include <matrix.h>

#ifndef _SUDOKU
#  define _SUDOKU

typedef vm_matrix sudoku;

#  define SDK_COLUMN 1
#  define SDK_ROW    2

#  define SDK_GET_ELEM(MTX, ROW, COL)      (MTX->data[ROW][COL])
#  define SDK_SET_ELEM(MTX, ROW, COL, VAL) (MTX->data[ROW][COL] = VAL)

#  define SDK_MTX_COL_1 0
#  define SDK_MTX_COL_2 1
#  define SDK_MTX_COL_3 2
#  define SDK_MTX_ROW_1 0
#  define SDK_MTX_ROW_2 1
#  define SDK_MTX_ROW_3 2

typedef struct _args {

  char *sudoku_file;
  int verbose;

} arg_str;

typedef struct _sdk_error_info {

  int err_type;
  int row;
  int col;
  int submtx_row;
  int submtx_col;

} sdk_error_info;

#  define SDK_ERROR_INCOMPLETE        1
#  define SDK_ERROR_BAD_COL           2
#  define SDK_ERROR_BAD_ROW           3
#  define SDK_ERROR_BAD_SUBMTX        4

/* Functions needed for this... */

sudoku *sdk_read_sudoku(char *);
vm_matrix *sdk_sub_matrix(sudoku *, int, int);
vm_matrix *sdk_enclosing_matrix(sudoku *, int, int);
vm_matrix *sdk_row(sudoku *, int);
vm_matrix *sdk_col(sudoku *, int);

/* These do elimination tests on elements in a sudoku. */
int  sdk_solve_square(sudoku *, int, int);
int _sdk_eliminate_num(int, sudoku *, int, int);
int _sdk_elim_by_submtx(int, sudoku *, int, int);
int _sdk_elim_by_rc(int, sudoku *, int, int);
int _sdk_force_to_num(sudoku *, int, int);
int _sdk_force_by_list(sudoku *, int, int);

/* Function to check a sudoku */
sdk_error_info *sdk_legit_sudoku(sudoku *);

#endif
